<%@ include file="/WEB-INF/views/taglib.jsp" %>
<script type="text/javascript" src="<spring:url value="/resources/js/restrictCharactersForDateInput.js" />"></script>
<script type="text/javascript">
		$(document).ready(function() {
			cal = Calendar.setup({
		          onSelect: function(cal) { cal.hide() },
		          showTime: false
		      });
			rebuiltCalendar();
		});
		
		function rebuiltCalendar()
		{
			cal.manageFields("button_dateFrom", "dateFrom", globalJsCalDateFormat);
			cal.manageFields("button_dateTo", "dateTo", globalJsCalDateFormat);
		}
</script>
 <c:url value="/deliveryOrder/search" var="paginationUrl"></c:url>
 <div>
 <h3 class="left">Delivery Order Search</h3>
 
<a href="<c:url value="/deliveryOrder/create" />" class="button right">
	  <img align="absmiddle" src="${imageUrl}/icon_add.png"> Receive Delivery Order
</a>
 <a onclick="$('.searchCriteria').toggle();" class="button right">
	 <img align="absmiddle" src="${imageUrl}/icon_detail.png">Toggle Search Criteria
</a>
</div>
<div class="clear"></div>
 <form:form id="form" method="get" modelAttribute="searchCriteria" cssClass="simpleForm">
 <div class="searchCriteria">
 <fieldset>
 	<legend>Search Criteria</legend>
	<p>
	<form:label path="search['deliveryOrderCode']" >
	DO No  
	</form:label> 
	<form:input path="search['deliveryOrderCode']"/>
	</p>
	
	<p>
	<form:label path="search['dateFrom']" >
	Date From  
	</form:label> 
	<form:input path="search['dateFrom']" id="dateFrom" onkeypress="return restrictCharacters(this, event, validChars);"/>
	<input id="button_dateFrom" type="button" class="calendarBtn" />
	</p>
	
	<p>
	<form:label path="search['dateTo']">
	Date To  
	</form:label> 
	<form:input path="search['dateTo']" id="dateTo" onkeypress="return restrictCharacters(this, event, validChars);"/>
	<input id="button_dateTo" type="button" class="calendarBtn" />
	</p>
	
	
	<p>
	<form:label path="search['purchaseOrder.purchaseOrderCode']">
	PO Number
	</form:label> 
	<form:input path="search['purchaseOrder.purchaseOrderCode']"/>
	</p>
	
</fieldset>
	<p class="right">
	  	<button type="submit" class="button positive">Search</button>
	 </p>
 </div>
 </form:form>	
 <div class="clear"></div>
 <fieldset>
 	<legend>Search Result</legend>
 	<c:choose>
 		<c:when test="${searchResult.resultCount==0}">
 		<div class="notice">
 		<span class="ui-icon ui-icon-info left marginright5"></span>
 		No records </div>
 		</c:when>
 	<c:otherwise>
 <table class="gridSearch">
 <thead>	
 	<tr>
 		<th>S/N</th>
 		<th>
 		<aims:sort columnName="deliveryOrderCode" label="DO No"></aims:sort>
 		</th>
 		<th>
 		<aims:sort columnName="deliveryOrderDate" label="DO Date"></aims:sort>
 		</th>
 		<th>
 		<aims:sort columnName="purchaseOrder.purchaseOrderCode" label="PO No"></aims:sort>
 		</th>
 		
 		<th>
 		<aims:sort columnName="purchaseOrder.purchaseOrderDate" label="PO Date"></aims:sort>
 		</th>
 		
 		<th>
 		<aims:sort columnName="purchaseOrder.purchaseOrderType" label="PO Type"></aims:sort>
 		</th>
 		
 		<th>
 		<aims:sort columnName="modifiedBy" label="Modified By"></aims:sort>
 		</th>
 		
 		<th>
 		<aims:sort columnName="dateModified" label="Modified On"></aims:sort>
 		</th>
 		
 		
 	</tr>
 </thead>
 <tbody>
 	
 	<c:forEach items="${searchResult.result}" var="result" varStatus="status">
 	<tr <c:if test="${(status.count%2)==0 }"> class="alt"</c:if>>
 		<td>${searchResult.recordNo+status.index}</td>
 		<td>
 		<c:url value="/deliveryOrder/view" var="viewUrl"></c:url>
 		<a href="${viewUrl}/${result.deliveryOrderId}">${result.deliveryOrderCode}</a></td>
 		<td>${result.deliveryOrderDateToDisplay}</td>
 		<td>${result.purchaseOrder.purchaseOrderCode}</td>
 		<td>${result.purchaseOrder.purchaseOrderDateToDisplay}</td>
 		<td>${result.purchaseOrder.purchaseOrderType}</td>
 		<td>${result.modifiedBy}</td>
 		<td>${result.lastModifiedDate}</td>
 		
 	
 		
 		</tr>
 	</c:forEach>
 	
 </tbody>
 <tfoot>
 	<tr><td colspan="10" align="right">
 		<jsp:include page="/WEB-INF/views/pagination.jsp">
 			<jsp:param name="paginationUrl" value="${paginationUrl}" />
 		</jsp:include>
 	</td></tr>
 </tfoot>
 
 </table>
 </c:otherwise>
 </c:choose>
  </fieldset>
  
  
<script type="text/javascript">
var validChars = /[1234567890-]/g;
		$(document).ready(function() {
			$('.searchCriteria').hide();
		});
		
		
</script>